#! /bin/bash
# ----------------------------------------------------------------------------
#
# Monitor a directory for .plot files.
#
# yqm_leaf@163.com
#
# 05/04/21
#
# ----------------------------------------------------------------------------

FILE_LIST=/root/plot_files
MONITOR_DIR=/mnt/plots
MAIL_RECEIVER="41731433@qq.com"

[ -f ${FILELIST} ] || ls -l ${MONITOR_DIR} *.plot > ${FILELIST}

CUR_FILES=$(ls -l ${MONITOR_DIR} *.plot)
diff <(cat ${FILELIST}) <(echo $CUR_FILES) || \
     { echo ;
       # Overwrite file list with the new one.
       echo $cur_files > ${FILELIST} ;
     }
